import { response } from "express"
import { request } from "express"
import MessageService from "../../service/messageService/messageService.js"

class MessageController {
    /**
     * @param {request} req
     * @param {response} res
     */
    static async GetUnreadMessageList(req, res, next) {
        try {
            const param = req.query;
            let condition = {
                receiverID: param.userID
            }
            const reslut = await MessageService.GetUnreadMessageList(condition)
            res.send({
                msg: '查询成功',
                code: 1,
                data: reslut
            }).end()
        } catch (error) {
            next({
                error
            })
        }
    }
    /**
     * @param {request} req
     * @param {response} res
     * get
     */
    static async GetMessageList(req, res, next) {
        try {
            const { sendID, receiverID } = req.query;
            const result = await MessageService.GetMessageList(sendID, receiverID)
            res.send({
                msg: '查询成功',
                code: 1,
                data: result
            }).end()
        } catch (error) {
            next({
                error
            })
        }
    }
}


export default MessageController;